package pab.core.service;

import java.lang.reflect.Method;

public class BeanUtils {

	public static Method getIsMethod(Class<?> clazz, String propertyName) throws Exception {
		Method isMethod = null;
		String base = capitalize(propertyName);

		isMethod = clazz.getMethod("is" + base, new Class<?>[0]);

		return isMethod;
	}
	
	public static Method getGetMethod(Class<?> clazz, String propertyName) throws Exception {
		Method isMethod = null;
		String base = capitalize(propertyName);

		isMethod = clazz.getMethod("get" + base, new Class<?>[0]);

		return isMethod;
	}
	
	private static Method getGetter(Class<?> clazz, String propertyName) throws Exception {
		Method isMethod = null;
		String base = capitalize(propertyName);

		isMethod = clazz.getMethod("get" + base, new Class<?>[0]);

		return isMethod;
	}

	private static String capitalize(String s) {
		if (s.length() == 0) {
			return s;
		} else {
			char chars[] = s.toCharArray();
			chars[0] = Character.toUpperCase(chars[0]);
			return String.valueOf(chars);
		}
	}

}
